

local obrsword_powergem_sign = Class(function(self, inst)
   
    self.inst = inst
self.extrapower = 0
    self.max = 100
    self.current =100
    self.obrsword_powergem_sign_damage = 0.0038*self.current*self.current
    self.sword_talk_cd = 0
    
    self.firelevel = 0
    self.greengemlevel = 0
    self.death = 0
    self.level4 = 0
    self.dragonfly = false
    self.moose = false
    self.antlion = false
    self.opalpreciousgem = false
    --self.task=DoPeriodicTask(1, function(target)
   -- self.current =self.current+1+0.1*(51-math.abs(self.current-50))end

 



end)

function obrsword_powergem_sign:Getobrsword_powergem_sign()
    return self.current
end

function obrsword_powergem_sign:OnSave() -- 保存
    return {
        current = self.current,
        
  
    } -- 保存当前值
end

function obrsword_powergem_sign:OnLoad(data) -- 加载
    if data.current ~= nil then
      
            self.current = data.current
        self:DoDelta(0)
    end
end

function obrsword_powergem_sign:SetMax(amount) -- 设置最大值
    self.max = amount 
    self.current = self.max
end

function obrsword_powergem_sign:DoDelta(delta) -- 改变的函数
    local function clamp(value, min, max)
        if value < min then
            return min
        elseif value > max then
            return max
        else
            return value
        end
    end
    local old = self.current
    self.current = math.clamp(self.current + delta, 0, self.max)
    self.obrsword_powergem_sign_damage = 0.5*clamp(self.current - 30,0,200)
  
    
    -- 其实改变的时候事件和需要传的参数都是随自己看需求写的
    self.inst:PushEvent("obrsword_powergem_signdelta", {
        oldpercent = old / self.max,
        newpercent = self.current / self.max
    })
if self.sword_talk_cd ~= 0 then 
    self.sword_talk_cd =  self.sword_talk_cd - 1
end
 
  

end

function obrsword_powergem_sign:GetPercent() -- 获取百分比
    return self.current / self.max
end

function obrsword_powergem_sign:SetPercent(p) -- 设置百分比
    local old = self.current
    self.current = p * self.max
    self.inst:PushEvent("obrsword_powergem_signdelta", {
        oldpercent = old / self.max,
        newpercent = p
    })
end
function obrsword_powergem_sign:Clearobrsword_powergem_sign()
    
    if self.inst.components.obrsword_powergem_sign then

        self.current = 0

    end
end
return obrsword_powergem_sign
